from django.db import models
class User(models.Model):
    name = models.CharField(max_length=50, verbose_name='用户名', null=False)
    mobile = models.CharField(max_length=20, verbose_name='手机号', null=False)
    password = models.CharField(max_length=255, verbose_name='密码', null=False)
    email = models.EmailField(max_length=100, verbose_name='邮箱', null=True, blank=True)
    pic_url = models.URLField(max_length=255, verbose_name='头像', null=True, blank=True)
    tscore = models.IntegerField(default=0, verbose_name='积分')

    def __str__(self):
        return self.name


class ThirdLogin(models.Model):
    LOGIN_TYPE_CHOICES = (
        (1, '支付宝'),
        (2, '微信'),
        (3, 'QQ'),
        (4, '钉钉'),
    )
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户ID', null=True, blank=True)
    login_type = models.IntegerField(choices=LOGIN_TYPE_CHOICES, verbose_name='登录类型')
    uid = models.IntegerField(verbose_name='用户唯一标识')

    def __str__(self):
        return f'{self.get_login_type_display()} - {self.uid}'
